﻿
Declare @DoDrop bit Set @DoDrop=0 If @DoDrop = 1 Begin

	DECLARE @TableName NVARCHAR(128), @SqlCmd nvarchar(512)

	SET @TableName = N'cc_UsersInEventRoles'
	IF (EXISTS (SELECT name FROM sysobjects WHERE (name = @TableName) AND (type = 'U'))) BEGIN
		Set @SqlCmd = N'DROP TABLE ' + @TableName
		EXEC sp_executesql @SqlCmd
		PRINT 'dropped table ' + @TableName
	END ELSE BEGIN
		PRINT 'table ' + @TableName + ' not found for drop.'
	END

	--DECLARE @TableName NVARCHAR(128), @SqlCmd nvarchar(512)
	SET @TableName = N'cc_UsersInRoles'
	IF (EXISTS (SELECT name FROM sysobjects WHERE (name = @TableName) AND (type = 'U'))) BEGIN
		Set @SqlCmd = N'DROP TABLE ' + @TableName
		EXEC sp_executesql @SqlCmd
		PRINT 'dropped table ' + @TableName
	END ELSE BEGIN
		PRINT 'table ' + @TableName + ' not found for drop.'
	END

	--DECLARE @TableName NVARCHAR(128), @SqlCmd nvarchar(512)
	SET @TableName = N'cc_Roles'
	IF (EXISTS (SELECT name FROM sysobjects WHERE (name = @TableName) AND (type = 'U'))) BEGIN
		Set @SqlCmd = N'DROP TABLE ' + @TableName
		EXEC sp_executesql @SqlCmd
		PRINT 'dropped table ' + @TableName
	END ELSE BEGIN
		PRINT 'table ' + @TableName + ' not found for drop.'
	END

	--DECLARE @TableName NVARCHAR(128), @SqlCmd nvarchar(512)
	SET @TableName = N'cc_SiteUsers'
	IF (EXISTS (SELECT name FROM sysobjects WHERE (name = @TableName) AND (type = 'U'))) BEGIN

		Set @SqlCmd = N'DROP INDEX cc_Presenters.IX_SiteUserId';
		Print @SqlCmd;
		EXEC sp_executesql @SqlCmd
		Set @SqlCmd = N'ALTER TABLE cc_Presenters DROP CONSTRAINT [FK_cc_Presenters_cc_SiteUsers_SiteUserId]';
		Print @SqlCmd;
		EXEC sp_executesql @SqlCmd
		Set @SqlCmd = N'ALTER TABLE cc_Presenters DROP COLUMN SiteUserId';
		Print @SqlCmd;
		EXEC sp_executesql @SqlCmd

		Set @SqlCmd = N'DROP TABLE ' + @TableName
		EXEC sp_executesql @SqlCmd
		PRINT 'dropped table ' + @TableName
	END ELSE BEGIN
		PRINT 'table ' + @TableName + ' not found for drop.'
	END

	DELETE __MigrationHistory WHERE MigrationId = '201208141342597_AddSiteUserForClaimsAuth';

End;

CREATE TABLE [cc_SiteUsers] (
    [Id] [int] NOT NULL IDENTITY,
    [FirstName] [nvarchar](128) NOT NULL,
    [LastName] [nvarchar](128) NOT NULL,
    [EmailAddress] [nvarchar](128) NOT NULL,
    [UserIdentityIssuer] [nvarchar](256) NOT NULL,
    [UserIdentityProvider] [nvarchar](256) NOT NULL,
    [UserIdentityClaimType] [nvarchar](256) NOT NULL,
    [UserIdentityClaim] [nvarchar](512) NOT NULL,
    [UserClaimEmailAddress] [nvarchar](128),
    [IpAtSignup] [nvarchar](50),
    [IsApproved] [bit] NOT NULL,
    [IsLockedOut] [bit] NOT NULL,
    [LastLoginUTC] [datetime],
    [LastOnlineActivityUTC] [datetime],
    [Version] rowversion,
    [CreatedUTC] [datetime] NOT NULL,
    [CreatedBy] [nvarchar](128) NOT NULL,
    [UpdatedUTC] [datetime],
    [UpdatedBy] [nvarchar](128),
    CONSTRAINT [PK_cc_SiteUsers] PRIMARY KEY ([Id])
)
CREATE TABLE [cc_Roles] (
    [Id] [int] NOT NULL IDENTITY,
    [RoleName] [nvarchar](128) NOT NULL,
    CONSTRAINT [PK_cc_Roles] PRIMARY KEY ([Id])
)
CREATE TABLE [cc_UsersInEventRoles] (
    [RoleId] [int] NOT NULL,
    [SiteUserId] [int] NOT NULL,
    [EventId] [int] NOT NULL,
    [CreatedUTC] [datetime] NOT NULL,
    [CreatedBy] [nvarchar](128) NOT NULL,
    CONSTRAINT [PK_cc_UsersInEventRoles] PRIMARY KEY ([RoleId], [SiteUserId])
)
CREATE INDEX [IX_RoleId] ON [cc_UsersInEventRoles]([RoleId])
CREATE INDEX [IX_SiteUserId] ON [cc_UsersInEventRoles]([SiteUserId])
CREATE INDEX [IX_EventId] ON [cc_UsersInEventRoles]([EventId])
CREATE TABLE [cc_UsersInRoles] (
    [RoleId] [int] NOT NULL,
    [SiteUserId] [int] NOT NULL,
    [CreatedUTC] [datetime] NOT NULL,
    [CreatedBy] [nvarchar](128) NOT NULL,
    CONSTRAINT [PK_cc_UsersInRoles] PRIMARY KEY ([RoleId], [SiteUserId])
)
CREATE INDEX [IX_RoleId] ON [cc_UsersInRoles]([RoleId])
CREATE INDEX [IX_SiteUserId] ON [cc_UsersInRoles]([SiteUserId])
ALTER TABLE [cc_Presenters] ADD [SiteUserId] [int]
ALTER TABLE [cc_Presenters] ADD CONSTRAINT [FK_cc_Presenters_cc_SiteUsers_SiteUserId] FOREIGN KEY ([SiteUserId]) REFERENCES [cc_SiteUsers] ([Id])
CREATE INDEX [IX_SiteUserId] ON [cc_Presenters]([SiteUserId])
ALTER TABLE [cc_UsersInEventRoles] ADD CONSTRAINT [FK_cc_UsersInEventRoles_cc_Roles_RoleId] FOREIGN KEY ([RoleId]) REFERENCES [cc_Roles] ([Id])
ALTER TABLE [cc_UsersInEventRoles] ADD CONSTRAINT [FK_cc_UsersInEventRoles_cc_SiteUsers_SiteUserId] FOREIGN KEY ([SiteUserId]) REFERENCES [cc_SiteUsers] ([Id])
ALTER TABLE [cc_UsersInEventRoles] ADD CONSTRAINT [FK_cc_UsersInEventRoles_cc_Events_EventId] FOREIGN KEY ([EventId]) REFERENCES [cc_Events] ([Id])
ALTER TABLE [cc_UsersInRoles] ADD CONSTRAINT [FK_cc_UsersInRoles_cc_Roles_RoleId] FOREIGN KEY ([RoleId]) REFERENCES [cc_Roles] ([Id])
ALTER TABLE [cc_UsersInRoles] ADD CONSTRAINT [FK_cc_UsersInRoles_cc_SiteUsers_SiteUserId] FOREIGN KEY ([SiteUserId]) REFERENCES [cc_SiteUsers] ([Id])
INSERT INTO [__MigrationHistory] ([MigrationId], [CreatedOn], [Model], [ProductVersion]) VALUES ('201208141342597_AddSiteUserForClaimsAuth', '2012-08-14T13:43:53.792Z', 0x1F8B0800000000000400ECBD07601C499625262F6DCA7B7F4AF54AD7E074A10880601324D8904010ECC188CDE692EC1D69472329AB2A81CA6556655D661640CCED9DBCF7DE7BEFBDF7DE7BEFBDF7BA3B9D4E27F7DFFF3F5C6664016CF6CE4ADAC99E2180AAC81F3F7E7C1F3F22FEC7BFF71F7CFC7BBC5B94E9655E3745B5FCECA3DDF1CE4769BE9C56B36279F1D947EBF67CFBE0A3DFE3E8374E1E9FCE16EFD29F34EDF6D08EDE5C369F7D346FDBD5A3BB779BE93C5F64CD78514CEBAAA9CEDBF1B45ADCCD66D5DDBD9D9D83BBBB3B777302F111C14AD3C7AFD6CBB658E4FC07FD79522DA7F9AA5D67E517D52C2F1BFD9CBE79CD50D317D9226F56D934FFECA3136A71922D56E3D3674F8F9F7F941E97454658BCCECBF3F74469E72150FAC87646DD9D125AEDF59BEB55CE5D7EF6D1936CB9CC676FB20BBF1935FCBDF2EBE003FAE8655DADF2BABD7E959FEBCB67B38FD2BBE17B77BB2FDAD7BC77D03FFDB66CEFED7D94BE5897653629E983F3AC6CF28FD2D5A78F5EB7559D7F9E2FF33A6BF3D9CBAC6DF37A897773C65FE9F068F5E9ED48F1F0EECE1E487197065BB5594B53DC43BC8326FE3588BE6E6BE2968FD267C5BB7CF63C5F5EB4738BEC17D93BF3C9EEDEC147E957CB82988B5E6AEB751E199CDFEBE3BB6E3A364FD2BA28C1B03F9AA300CDD34BEAEA665C7FEE279A7A7D915D16173CAAD8203E4A5FE5257FDBCC8B9508FBD8CCFAEFAF4D9ED5D5E255852EC26F7EFFD7D5BA9E621055F4EB37597D91B7B7C7E855552D9A2846F8E6F7B7CCE821147C613B34F884DF1A6CBF962408297E24063E9A4F8B665566D73F2446EE74FE7A5ED5EDD7E81AE4FCB09E75D84F89ECEFD9F7A7FBDF50DFCFABA9CED07BF5FF0D90FD557E51346DCDBD7F55973F7C045EE70D3CA5D7EBC9A2E0DF9A2F57B9250426E54D01A6F860B0276585D73E10AE988AE6E57A52165303ED4945EA295BBE37309DFDD7C4F95FD6B3BCB6D8E5D36291D164BCACE937753889D2AFA71960BFBF6D62AC5FB759DDFA5CFEB58940784F2B72F7A6505475DE10F0BCA636E745999FC81784F371595657B9557D5F9748706C67EB32FFA688FEB22EAA9A09A218BFCAD74DFE0D21FB828C2063A91DE497457E05E3F59E82756F67835CC9DFB7B5C24FD45EC62DB1F9F646DFA06B8B3B5FC78CF126AC4EAAC562BD24BBF67A45F854751CBB6EAB3E96F1163D6C079ABD2FD667CB597159CC28FC2236A7999CACDB21D4A34DFBF86F68D61BC4A6B6EF3B122BB671ECEDD77D8C3B5FF5B0EC7EFFBE98A9E68EE3A55FF6B10ABEE8E1147EFB3531BA81640ABBDFD62139D0A4E7770FB57B5F07FCF52ACFDEE6F52BD2F30C7280A69D5611E2465BF4A91C6FF6DEE4DEA4110615C166F9FF30B1A7AC461C1BFAA28F89FDB08785FBE6FD3168DE0EA1D0BC8DE1603E8D2061BF7A6F2CC85968CA6A808FCCB7116C826FFA18855F7F505CD755F43F0AF122EEEB8DB8DEE0E464EF1DA57D0381C2D7884E76F6DE3F40FB1AF995AFEDA574F5FE0DCECCD71288A8D3F023A9782FA9B8157F3E2BEAE6EB2430BE01D1789EFDD07AFE1AE2F10D78C25D41B98DD7FCB5A4C53A5B3F92906F5E425E176DFE5593D71BE04443DB9F9782D675BDAE0ACCFA37DEF96D087EBAC88AF2783623D968BED1CE6F3572E118E1F4B3A659BB34D92D71D8BBFFE93789037D45AAE7E71A8B93322B1640E0FF0568BC270AF7773F38654F6FFFA2B5EA1220725EBCF77CECEEDCDF94630BD1D84009A6C0CF9A84DC463CBF9B4F1A68D66FDA3FBE4DDF4FCAEAE2E7A4E32FAA09A56E5FCEABE57B4BC07BA756BB666C5ED4EDEBE207EFDBF1EE87767C52E7B0FF5FBD39313DDF3E83FF35FCB6F7C80176FDB3A11CE16D91329EC20D78B96631D4CCB71BB0B34DDE1BC15BA504BBAD7E7FE75EF6539791564379CC58D3F7CDE578C93AFDF5C6ECA0FE3A308A0DED36650AFB8DDF7724F6CD2745755167AB7991DF90D4360DAFE343D9D46E38DD1D6BFC41A92CCBDD3F0A457EDEBBFF3F6B0EC6AD7AF73DBE1FB9E03F72C1FFDFE3FB9EAD8EC915BB58AE57EFD9F546E7FF563D37C7AB15F1616EB5E6938A0C42B67C6F4A9E35CFABE9DB7CF6E5BAFD50505050CFAB8B6279838F789B0102D697CBB258E6C7D396B26DEDF53700F427C9CD601DAFE32C96594D4683B278D3755DE7CBE9F5173C233C7B374E22FDDA4760D848517A7DB56E01F767DD487D88AB1E07F5E4FA3D39FC9BD0FBABD92D46719B795748DFF020FA3DDFDEB9EA78D29B9CAC7044CEC9B22FF7BDAD687BEDF3EBF86641579B9DB41B825787C37B81B9D9FBFED98980BAB1DB2D82A5DB62AEA06E87B76DBC016BFDE0669C4DC30F5AAA3018FD283A081CE56F62A1E24DD196F937AAA96ED5EDD3BC99D6C54A86F95E9DEFEFEC7C703253F9E90B9AB9BAA017BE465AEF3D95F5376B36BF4686CBC8612FBF157C3124CF5F37B7451C3F5B97F94CC10CA45D3AADA20A68A04D3FDD32D4F07D532D5F33EDF53ECAF3C694D707E2FE26BBD888357DBF015FEFDB214CFD261F96FFE9CCDA8F347D80E6ABAA5ADC8CEAAD74DE878281826ACAEAFDEDCE20B36270B7D30BD27283524083BE0A8BB67A6F5566E4E43688BE8F02BB11DDAE0CDE16633353B743D9B5DE80B3697433D2B6E507F97D3CE13F52053E9A4FD64539230FE5667437C3C1BFDFA8CFF39E526FC611E54E9650D7C27164F0458F0BC36FDF575EBEA6B3723BA574A39B12A8AEAF252C56823F4C606CB7FF3F11986F244AFA21494B3748229ABD7F70D065EB36AB5B7953207D2D28A7CBD9FBC3F81A618AB51BBD3825FCA627FB9DAF7F48C2FF7E56F34625D0B3AF5F4B1138E7FC47AAE067C505CEDEDFFA7E3DBFD24EE42DC3B481E83D16C9DD163F70D10DB87193285EDCF1304EF2FF0FF00F7FC4E2DFB0B5FBA15ABBAF631E8863FA96C17CD8370AF69BF7657BC7A537665036B3FF86CC892F1D5F8BFD5FAFF2EC6D5EBF2266D35F7F240D019ADFDC529290F7FDF3C47BF73F7DDF3CF1D75D7EEA31835B2F0AF87343BBBEB2DED4F88354B705F3A4A82EEA6C35BFFE11EFFEECF0EE494550A031DF8B71BFD632CBD764DD3E2FC4597753BB1EEB6E6CFC41ACEB0985D8A21F31EE371E7033909F5B75BB612DADC3009145B5688B4DEAD56FF681DC49B8563FF2043A682EB28BFCFDF96977676FFFBDB560ACEB6FE7C5C5DCEAE0AF27130CE8BBC5AC9D7F189C6F44407F483142A7D71FD20C7E2D9DC062175305DE17110DE07FFB4182FF266BDEFE48EAFFFFC2E92FAA366FDEB7DBCDBCFE4D993F305A2C0A379F46C270FBD5FBC6E178B5B179D1782C1EB6F9FD590E3A8875BEEE45E5B1361F149A87007F2496BD49BD19D59B6118F2BE37AC8DECF64DF1584C0A86F8F07DF0DBB8AE1FE924B646B1A1D96DF0FE6656F703E47E24213E9AFF5F5FF9EBC0F8C9AA5C53DC9DD7CD8B3C9FE537CEC1FB88C3D7B00EEF2B11B7B016DFCCCADDF3EA823EABBF562ACCBC7BF6F4FDA5C2BC8B77EDCC7CBAFFFF56E9385EADCA62AA4DDFCB43BAFFFE39AD3EA930D7CFAB69664391AF2DA104ECE9046F7EF5E6E4C381E597F9FB4747DF003D2E90A57BAF6E3FFDE06EBF6AF2FAEB38E61B939A5107B9D3F1AB7C419EF9D9CBF7ECF8DEC30FECF78B6C3A2F96F9CFC998DFCCEB3C9B6D309DB701D25B7CBF25FA071F8AFD57AF9EBF6797F777F73EB0CF2F68B094AC79CF7EEFED3CD8D4F1AD04E3F4DD345F7D0DCDB8B739DFDF1FF4AD8D1A6CE6D73168FF3F76EF4092AF23C9EF9B56B8F51C419D9E2D3944FFBAD385F7FA53166DFABA6873EEF16BCCB0E9E6BD1CC8AE2AF2FAFF1038DF487AE984742BB1E137E10128A827D73FDB7C956EF0C9997F628E7887C77E7F69E83CF0D8F7BD6034DAE87DA36833FFB742D3351E46D5B4B9115DDBF07D511ECEC675BBE825E6A20D6EC4F41B48480BC81FE9935BC3F979A60A3668819B14C0CFAAECDF20F6B791F89B857D488A8E9BA69A168C9899CA6AB1582FA969B8C4148E97B234A920106FEEF0146EC068BB2D8911D6655B20B6A60F3FFBE85B3DAADED88BCD94B85E541F85A0777BA0499AF31A0E58569E10C4B6CE8A65DB17FD62392D5659792B2C3A6F47554754C3DCB5FD74BF799AAFF225FCC45B11FB3608581FA28F85EDACA3D26E22D5E3BB1E136DE6ADB3E5ACB82C666B86441A62B26E6F64B00DEFC4B82CDAFC7D586D537F3F647EBB052AB799F30F64BA5B4CC06DB0F8B9E5BC9775DE10A4FC266EEBB48B71986DF23E5CD585FB43E6A481EE6F336F1FC83D0304BD4DCFFF6FE1186B9B6F9EDCBE9DFEC6F8A667DE3DD0CE7B0821EF8CC7DF380375F1B8CD4CC627F16BF05097BEB7E97CD85DFF217192A622DD281C270C4DFBF02B31CEEAB67E1F06DBD05384D106BBF886D8EC666C6E33E31FC86E3713FF3648D8977EAEF9EE068B17B4DAC05D5F83A97E6E6C5DB4F3DBCCD837C336FF5FB373AFAA6AF1FB3F5917E50C01FBD08C06AD625C8206EFC32221C0088B58947E76B824DAFF6D66EB03B9244AC8DBF46BDEF9396394D7B42A315B97F9CC303A4FF9A00A88B58E30CEB8DBF07D9828DE49849962DCF90D31D2461C6E33B11FC8501B097D9BFED1FEFF3D4C65B8E0D6536E7F462CD737C95AE667CCFD8E83FFD962B00E26B799E36F9AC73A44BF0D0ADE82FCCF09A721AFDD94557B833B14368B719569F13EDCD481FA43F688E2BDDF66D23E906FE2C4BC4DC73FB73E518FDFED9CDF5A5DD8A1FF6CEB25DB5184A98658F51BE2AB1B71B9CD4C7F208BDD48F8DBE060DEF9B9633841FE4D7671B301EC35DD10B451ABF762AE3EEC1FBEB91BC4E13633F9A1DC3448DCDB74FE736EE208ED1BAC9B6911356CEFC72C0ED60FDB9C753BBECDDC7C2063F408779B3E7F8E8D98E365CCEC2D649ED9FE674197C8FFFBD6A90FF01BE29078DFB799B20F649338316FD33135FFB9E6142FCD793B1BD47BE1BD92D3B7E7A17E3F3F5756691093DB4CF137C35B8344BF0D0A3FD716EAF52ACFDEE6F5ABACCDF5D7DB2C866C7829CA71BDF6EFA5B736F516E1BB9FF525915BE0739BA9FF50EEBBC524DC068D9FFB65118BC193A2BAA8B3D5FCFA163CB8E9A58D8BBDB6FDFBF0E0C6DE7E0E78F036F8DC66F23F90076F3309B741E3E79E07D595EC68F46690FD06DAC7382FEA79EF8CC77D56B819FCB0991DE4B80E5BBF074D3C0D23F8DCB06E196D7E833D8812E796D6C0EFE5871CF16CC6E2362CFF8192B799D8B741E0E738165A1180AABE91A5BC56714EE206EFC7403ECC1F3ADF443ABFCD6C7D30BB4408799B7E7F6EB9E44DD6BCBD3181629AC43328CDDBF7610E0FDA0F9933FA3DDF667A3E902DFAC4BB4DA73FF73CD1F8896D9AE14DD3D9693BC425AED9FBF24BB78308E3C4D8F01BE49B010C6E3397FD697C6F061A20F06D7A47FBFF3731D28DAB4A1BDEF95967AC8DEB4A3EF23F3446FB39585DBAC504DC060BFFBD9F33067CB22ECA59B1BC6989206C166333D3E27D18AC03F5876CEDE2BDDF66E63E907FE2C4BC4DC73FB756EFAB8682E325E38081FCFEF8679063628D637CD369F73EEC13ED22C24431B8DF100F6D42E13613FA819CB489C8B7E91EEDFF5FC34EAF8B36C767B76629F3C2CF325BD96E62890FFDEE87C45E5D546E33C7DF308B75897E1B14CC3BFFAF61B5CDC62EDAFA6799C97E4E2CE046246E33B1DF306FFD7FD21E5AC57B033FF514749F93BE1E1339C03F17B6AFD7FB6DE6ED1BE19B1E416FD333DAFFBF81616E69ECA22AF71B659C9F73EB16C5E23653F9CD31D1FF076CDA29BDD35ED33B2DBD91D78AC44935CB4FB2C5EAE904DFE4EFFA360D6FBDCE5B13ED65CB653E7B935D341FA5F29D1FC1992F238CD301A3014C148A8D036F00C2BA3B06412DDE0DAF9F548BC57A898F24AD1C83D46D7323D0B3E5ACB82C666B9E9DB62E26EB360E39DAF046F0DE9A5E1FA4B778760318C37A31284E646F02D25B668C00EB2DEBDD0EE80658378398CEF3D9BACC679B6075DADC08F455552D6280F0F98D2F9B1C4D0C80CB77DD8E3203A2E7BEBD11D00084DBBCEAADD7E9AF515C7AAD6E04DC5B822FF28D1C6E57EA6F84DC5D62BC01E1DBA98E0D1AE3B68A825380D1694092FD362F7B19D92814BFC12DE06D64D220317B03B0E7D5C529345A7406F5CB9BE70D66352E7070546E7899759B1717C400754287DBC2DC0C2E0AC933C8C3D64723CAD46B3C608362B127E36B7CB3F80BD6F7B3038B9AC09E2772235CE3F679708DA47508E1BB26D4EE16548A5AC961526D6A3E3CAE0D6FC5883664E237506E530F3F9BE4B3FA729864DD26C383E8B48C91C6F7053690A30BE9874302E7D86CA2423CAC1A40BF17577D082D7A719407CC73D83E98225D9FECF7F7BCB33E6536B41E1ED4F04B314A451CC90D04DB003B42B861A05F9F72C3C21436B8710CC382E45CD79B29F143102278B9BFBF8BCBFA030F1B0CA31CB48B0D5CFDEC0DA30E417447DD6A6C29B1E5070FBC1B27FCFEE2EF47663EDA70C3DCC5DA4739A11FCD6C628928D80891A274FE26086403AA5BD0C8B47D8FF1D89FDF38A5CCCF98F61D00F835E86597F9077548A7C5F008C286318A782EFD064A74E0FC6CEA911ED15D50710B76B18DDF6356EDE0BE7986B1A023141BA4FCD7219AF447F1F946E1EAB7BAD172788D371821C917DC6C877C683FCB42443D0DCB8FFD7203CB9B3651A9B969BCEEED9F55597154E5D4CCC629478B5B4D104FD23732D5F2FF3EE747407CFDD17B7EE38DACDF6F7BE3387AAFFC2CB8A73F1C91E8E7DC6E70EB37B5DF30BA0DAF4569174B186EA2DE26F83FDBEE7D3FBBB899861BDB0F8F71D36B1B03C920377A9B9032D6C1CF361155ADF665A64FBFA1A6C3231B782346B5B81EBE15B46149FD4629D5CD3A6F082BE32D6F2546DE0B3708E82D283600F767D50CDE941EBD6D56F4C664E8AD72A03FBCD42772EE9BBC1CFBED2647C5348AFB39BC02B1D1D1B1EFFF6C8FD42D56FCFEB202121F72B7D966DC3BAD078930B8507223C4A8031421EB3743954DD1D2A6E6EF35A64D11D387516B63C014AE407D30F56C826850823A2D864712368C91C5B4D82C4D1D383F9B12F555B8B6F5FBE39F180DA2ED8647106B1EA307DA7596DF36D0250A35429D28A46F80389BD60506DBDE7E389BD6083E8C503FAC05836EBF8322156F78FB010D0AD887D1E987256FB710B5DB4BD96D04ECB6A4F8218AD52D25EAFD84E9B672F4AA7A0F7A7CD3D2F3F8AE00C00A6F562CF3DA7EF7F82E72878B4C3F787C979A4CF3554BCBC15F54B3BC6CCC175F64AB15CC887B533F495FAFB229A17FB2FDFAA3F4DDA25C369F7D346FDBD5A3BB771B06DD8C17C5B4AE9AEABC1D4FABC5DD6C56DDDDDBD939B8BBF3F0EE4260DC9D0691D5E30EB6B6275A99CE2EF2CEB758FC9FE5CF8ABA699F666D36C91A9A8093D922DAEC245BAC9E4EF061FEAE23FEDA2B51CEF4A7E63A5B2EF319E78EFA938737DE5CAF72F30A7E97D74C6FE3D3674F8F9F8F2D942E1047C96734B805493D8F534729367CF85D7AFBF5342BB3FA655DADF2BABD56A4CF664483AA5C2F96EEEF2EEF0DBF8D7FC3F7E5933E84C7773BC87749A49CE7D1A8C3B45DAADF6E4EAC57F3215332B026789B19197CF5676742D81A7441D80F6F0FE7FFF513AB66EF0366356AD86F31A503EFFDECCCE7D3A25995D9757F3A822F6E0FEFF5BCAADB3E34EFE3DBC352144897C671932FDE1BDEF36ACA96290AD37D797BB8AFF28BA2696B7EEFABBA0CE1F6BEBC3D5CCDA7BD5E4F1685E4C0BF5CE51DB487DADCAA9701082765D574E76FA8D1EDFB1125D1BC5C4FCA621AD31FF6ABDBC3D4497B4DCCF5653D832F159952EFDBDB4366945EB759DDF6D9AFFBDDEDA11246D38A4CE8B4CD67364D4A6DCE8B323F912F88B6C765595DE51DB17ECF576F8F9359B28D4F4DFFDBDB437E591755CDC4523C5FE5EB268F8EEE86A6B7EFF305E59F195105965F16F995841B81B1196EF6FF1A0B74522D16EB25BE3139D70F30465D605FC32EDD0CE267C744FDF05D8E21083DE53EA0D07F8E18E66C392B2E8B19454C082BEA62B26E3F906BA210BF06EBDC12CEFFBBF98703BB3E13791FDF1ED6F32C06CA7DFAFF1A9EDAB8E2786B3E1A5CF1BD05EF6C78F7FFDDFC62F2235D50FEE7B787F673CB7D4390DE5C152D4D4D1F58F0C5EDE19D2EB2A23C9ECD68CE9BCE0404DFDC1EA2503A677E3A6B9A75D7498C7DFFF5A0D357A4E336C1772DBE5E0F2765562C2064C35D784D3EA08F1BE0BF17EC65F18BD6CAEF00715EF428146DF11E3DD09B8CD630F30C34B97D1FDFCD270DC4B6EB00F89FDF1EDA93B2BAE881B21FDE1ECE17D5845CE597F36AD9E188E08BDBC37B3D2FEAF675F1835EF06E3FBE3DAC933AA7E068F6D59B931098FFF9FF6BAC9C4B657F80911BCAD4DFC2C60DBFFAB360E2FE5F6B4C7EA4FC6F54CCFF5F53FE3F04D57CB63A26E574B15CAF3A4E9FF7F97B406B8E572B9AA96E82C2FFFC7DA0513EF16D3EFB72DD76C1795FDC1E1EA4EA7975512C7B6A35FCE6FD207EB92C695DEA9812489734C951D09126B7EFE32749B1F6F2ADF6C3DBC3F97A26E506684FAEA3C0F0F1ED617DB59A4531F33F7F6F685DCCBC8FFFDF6338252FFCCD44895D605FC790DE086288E8F6956EB8167C71FB49544C7AC19FFBF8FF6D93F84DCCDDD79FB2DBCFD4FF3BA2FB3745DB4D2AEB47B787F1346FA675B18A2C46F95FDC1E9E92F20B52137591954D2FC68836B83DFCAFA7807FAEB85A572E66DF087B77807D1D3EBF11C4CF0EC3BFAAAA451782F9ECF650BE8E3A1B169D45DE94554F0AFDCFFF5FC34620D507B10E007C0D7689BFF6B3C3224FD645392364BA50FCCF6F0F0DFF8670E493FFD74CA9E1B30F9A5603E46B4CEDF0AB3F3BD33B68F2DED3E4DD7E62070D5E6F2DFD7D57D079D91D04ECE821F7F1ED619D2E677D48F6C3FFD7B0ABEAD837D9C50731AC03F3355876D3CB3F3B4CFB8D1A9CACA7DAF4A3FFD74CF287CEEED79BD61FE27CFEF095D0CFD14CBE5EE5D9DBBC7E458A4D7FFDA089ED83FB1AF37C1B203F3BD3FE8D87D5827E3FB2F13EFF7F0D2BD8313E29AA8B3A5BCD8BFC8378A107EFFA6BF0C26D80FC7F83174E2A7A67D9766251F3E1FF6BB8C0133ED6771FC4025D605F83016E06F1B333FDDF9405E0577A0AC07DFAFFA289A7AC43F5A1EA9F617CAD691E78F3676776CF16D9457F7DDC7DFA9E90BE9D1717F38E68075FBC27BCEF16B3761E01A79FDF1EDA37C5C5F8F7767ECC10841EB1FFDFC5FD6FB2E6ED07B13E007C0DBE8FBFF6B3C3F4FFEF618617559B775656F5A3FF7731C4EF3F94FC785FCE1886744B1ED904E067875BD06B3F0E95CFDE0FCA6006B5F3DDFFABE6FE9B49BB7980BEE6C4FFB0A7FDFFDB49AF21383F49AF93A74DD1ED8B3C9FE51D0AF5BFFD7F0D2B3EAF2EE89BFA03433185F27502B0E15787686DDE387B1A52D9FFFCF63377BC5A95C534EBAF3A065FDC1E1E6101E6795ED1973DFCBC6FDE0BE2D309DEECAD3486DFBC07C4FC32EF22271FBD078CEAE28212275D7CF8B3DB43F9AAC96BFCD671DDECA7B787F42A5F90853F7B1942729FDE1ED217D9745E2CF33E5AC117B787F7664E0BC2B39E71B29FDE1ED2379905FEEAD5F30ED1F1C1EDDFFF823AA588A14321F3E1EDE19CBE9BE691357FEFE3FFD7E8CA5755F9616A1200BE868A8CBFF6B3639ED1579FF3DDA7FFAF990CE888E66CC9E1C5074F0C8079B0BEC61CDD086113C1BB53663EBBFDB4BD2EDA9C51E8AA06EFF3DB43FBA602B91352716D3EEBD92DFFF3F786F6E43A0A0C1FFFBF8D39BF21BEFC2096FCFF3E37FE6C7291CF453F775C74DC34D5B46057B3C74A2C76BFBF9A78BB3440998C41A6197C636019DB368970EA2CA619FAB07FFFD7D5BA9EC698F456264AA0C6B80294B3387C7DF4DE64F5451E8B90A3E87DDD95996FCA69DB38685AD19915E094F4AC79B12ECBCF3E3ACFCAA61BC10E10F4F1DD28AB796D0CAB62E1282367B7EE36B1B2A09FD8BF1BF301D88C9CC02F882B4BF32113679E2F32264AB3CAA6CAB7CF8ABA692903904DB22697261FA534F6CB6296D744A5EBA6CD17633418BFFE45E54959E458CD320DBEC896C579DEB46FAAB7F9F2B38FF676760E3E4A8FCB226B40E0F2FCA3F4DDA25CD21FF3B65D3DBA7BB7E10E9AF1A298D655539DB7E369B5B89BCDAABBF4EAC3BB3B7B77F3D9E26ED3CC4A9F573C8DAD73FA245B2EF3D99BEC2264A9C7BF57DE9B2F338FAFF2738FFBBBD3D27DD1BEE6BD83FE3FFBA8C0F859923FCF697AA0B45E662DF1E412AD72C6F4A3149C914DCADC7247A7C30E78FC6B3A585E66F5749E5118F745F6EE79BEBC68E79F7DB4BB777003505F076EA6DDBA2867C42FFF3F219D758BBC3EDE13C40F93FA9135CEFFCF92FE69D1ACCAECFA1B205F1FF6EB7955B73742BEB7F7DE801569497A6E00FDE9FED7058D049344CEDF304D5EE51745D3D60C9C57D7BE61F86A125FAF278B827F6BBE5CE5761833A2585B60423E18EC49593596FA5F1BAE487EF3723DA13CA1813629DE5FFE75DE5E13C77D59CF904053CCF269B140AE90FC8E6901CC89AE4456B819F4F5FBF31E63CC79729FFDBE360108EF694586700A6936AE11B5392FCAFC44BE209C8FCBB2BACAAD26F83A04825F305B5314F20D10FB655D54351342317D95AF9BFC1B40F205799C8C9D02CF2F8BFC8AA3AF8D1A64C7EFA8ADD75F57B19F548BC57A09D77E451C5E759CF9FFCFEAF8FF7798D73ED01BF5DFCEDE4D0AFCD6537B461E3FB9BBEBAC84575E179375FBA3F975203884F85999E4E7D93702F8D6133D1089FF7C9E5C3F651485D25799FF1FE4903EE0375705A8FFBEB06F438DD3455694C7B319319BA6916E07FB5678CB5C09BF9C35CDDA7933D12EF6EE7FFA415DBCD444C0CF6A272765562C00FF67BF978D3DDCDF7D7F97EFAB65F18BD62A41E8E7BCB88158BB3BF70397E476BD107CC6FFEBF2D66DF8F6BBF9A48136784FCB7B1BD04FCAEAE26703EE17D5843CCC97F36A7903EFDCE00546F4E2BCA8DBD7C50F6ED00EEF0DD74FB60BE05B8607B7367246A3FFBFC1C67D0336EEFF83B6E5EB0AE9AD80FFC8007C502FDFBC01F861A8E6B3D53129A38BE57AB519FFF7564767CDF16A4553FC61A1F9594339B1B7F9ECCB75FB21602090CFAB8B62798376BCCDC000EBCB65492B2CC79425B9A4E9FF0680FE24AD757989BFBABABA349F0CB8F6943558AD5B50F7FD7AFADA66621014565E6FCF94B782FCD56A760B246F335C85F47E38F601DFDE466E5C99BD5D3CB871B132D27E7041F2E63032E84A08F4B5623D87C1D707E2963EA330364CCA2D27E5EBCCC5D721EAFFFB63F337455B7EF3DEC9D3BC99D6C5EAC6158CFD9D9DF70F54740EBF201AD605BD70A3D3FFFEB6F06BABC6DB6B074D87CFFEFFC591AFAA6AF1610CF98D28903734534D59BD976CDC7AEA30C6FF9F4CD7135DC77F1F3AF5A1E0DFF791C00F21BE99D9FF9F4CC037A0C1BF01EA4714F837B1B6C8AB946FF84D81F4B5A09C2E67EF09E3D6CCA4BAE64D76F1C362A76F46BB651F28B0DF2853DF9ADA3F44327FA303FC7FABD4DE9AF0AF5779F636AF5FD1E0F5D71FD63C7C4341C5CFF2742A516EF2233BB9A10F88422C599E14D5459DADE6D73FAC09F959A6E43734DF5822CFF1DE86D9B845E870EBF9F0048445FBFF27B3F10DA82906F1C3138CD7AB6AD954EFA59EFE5F4CFFB34576F1DE4B5DB787FCEDBCB8985B21F93AB3CB60BE5BCCDAF98740F906D8EC1BB0867DA0DF00E56FCDB86FB2E6ED8FB4C6CFEA74BEA8DAFC86458F1B5777DF6B3E9BDFFFFF67C12606F561130B083FABB915BF83FF9F50FDFFD3A1741FC64F56E59ABC335A937A91E733B7A6F70D3201ADCFD167F5D7728ACDBB674FDF9F11FC77655093E2E26785276841B42CA6D98DF9F1FBEF9F1DA741608E69B134B3E6EF6BB31D017B3A01B8F7CF844780E597F94D16F9FD8156171714CF6E82FAE9FB43C582FBCD462C0C40FAD6A60FF755BE202B76F67223DC7B0FDF17EC17D9744EABD03F1B18BF99D352C86C50D7DF06442FE715C5EDE0BD51FBEAD5F3CDC2B3BBF7BE20BF2054C925DE3C3D3B0F02B8B762A8D377D3FCE6E5B0BD4E4CFB010ECCABAACCBF8EFEFC7FA101C5506E66ED1B3DCA5B930EC27FB66437F8EB5211EFF529196DFABA6873EEF16B10DE74735B0B1C914DAFF7AF0FE51B0819BEF68A6B08CA03F5E4FA87CB303FE2955B41F9FFD0441F374D352DD84BD31E9FE87AE9EF1F4B1392779D82CA2A0F06A9D779793ED64FBE58976D01D78F7A23CC7A0374204C4F0114F76108E85B3D40C433790D7D9B95944C6DDA3AA3B9EA3358B19C16ABAC0CD0EEB48A3262945FEF5A78DD6F9EE6AB7C09F5DF1DDC6DFAB2CAA5DFA185DB91859B46FFF8AE37B59B67FCA45A2CD64BA2B2A6267FF667BEDB6300ADFFE5FFB739A1379EDBF4F973CB1167CB597159CCD60CA9AD8BC9BAFD61B045B4DB00E4408BFF6F33487C50EEADE18E7F6EB9C4AE84FDEC7386ED2A00E37DFAFF6D0E7003B94D67FF6F9975E32C0D4EBC6DE04F9AFB309CB39DF1F8FF7D1C101FA236FD396582613FF987C4079AF270EC3080FFD79FC34DECD0ED3D64B1DE973F2BCCF17E13F681DCD11BD36DFAB4ADFFDFC325FAC1B0CED0EF23F3F9FF35FE880E555BFEBF813BBCA4E5CF096FB01D330C61516F3ED48FB8C190FCBF81337E688EC5D7E20B99979F33B6509C7FF69DCAF75035FF1F9DF75B75F573EB4EBE9ECEF3D9BACC6766DA5F55D56270D6F94B7FBEE483F798F34E77E1E4F7BEFC59E182FE08B5D937CD04DDE1DCA64F20F7FF1E66F861790BFF2FE08AF799A49F0BC6F8B9F6167ABC8135FBA6AC864D846DE0CFA6FBF0FF5BEC111FAD36FD7F037F18047FCE18049AEBF77F124DBB7B73691BF873E83EBC3D53DCCA147D43931F1F9536FD8627FFD6D6C920F57336E186E37EF63DC5F7D224DFD09CFFD07CC5F7D22C3FC7CEA2E8A337D9C50FCD33B03DC620F1C73F2BB3EF0DCF6F8796DFF4FC7B63B90D07FC9CFB018E077A28FB22DB99B1C854FDBF71DE6F3B0B3FDC39A7763F67F38D89FED957F03773CB3734C13F3CB57ECBB9FD39D6E8AB3C7B9BD7AFB236D75F7FC8EB08BDFE43798F7CFDB3C216EF97A1FB40D6888CEA36BDFEDCAF26580C9E14D5459DADE6D73F5C6EE9F71F87E97DFDFF7D6E898CEA36BDFEDC738BC7E692D2FE593723DD1E87744914F037C41B3F3403D31BCF6DFAFCB9B63604A0AA7F188CC01D75E65F3FFBFFFAB4CB306ED3D5CFED6CBFC99AB73FFB538D5E3ABE233EF8FFF624F3186ED3CFCFFD0C373611FCFBF7B17EDF79BA69A25D673D50FE573F2B937FEB39F906E6DE1BCC6D7AC42BFF6F62829B9706FC46DD99FC3A4B04FF6F608EF79AB29F1B26F9395F24F8AA218774C95A0B03F9FDF1CF2097F097FE54CA07B7E78A4E6F01ACDE773F2B7CD11F9F36FB86F9A13B9ADB748986FFAF6184D7459BE3B3E184B26910F874F6C3FF2F31457CACDAF4FF058C61F0FB7F0D73FCAC3B911B78E287C4133F34D7F2EB30C4CFAD972918FFD0CCC58052F8599CFB5BCFC33732F5B7EEEDFF05F6E1E7C434FCF019E0876F106ECD043F645B704AEFB4D7F44E4B6FE4B5227152CDF26745DDB44FB3369B644D5F07E0ADD779ABED9F64CB653EE34524F9CA9B4CEFBBD7D379BEC83EFB6836A968BEB309C8339DFEFEB6451361954E47EBA29C15CB683FF6ABA16EB4C1CDBDA839EB75A19F0FC0E76F6F067E522D16EB253E32F9B15E3FFD26035D761BDEDCFBD972565C16B335F3495B1793751B4561A0DD001ED1D63723E3AD49F41070DF0D756A5BDCDC91D34DBD7EDC5703DD9806B7E8451699378DAADF64A8D74EC35BF73EDCE94D7DDDA20B7A7FB62EF3D986BE7A4D863AED34BCB9F75755B588F4281F0FF4822F6F86EC72153DE8EEAB811ED0E03535B8B9171D685C4BFA5F6E9EA65BE9C978279BA0DF0A6C6C79B83F9448A3A121F59ADE8C436CD171587B788D6E5223A66991DF8C447F6D6B131936DB8D7EC31B3B1F321C37D98B5B9B09C9154718081F0F7210A5C86E05D9CF0E46FBF01B6CEAED3DA42F4C74467BBD559FB7EFF17975411FD531F6745FC57ACA9AD5326F5F5D34BF7F595DECD3AF377625AE724435E2E341D558DE82D17BC178AF935E8B81FED8867A0D6FDBF7C66E6FD363BC33CF1FEEBB979A0049BD461D2F339622E121749224764CF6939E53EFDEE97AB7FC9AFBB03302DFA5A796B7185ED75D1C1EE640CB6F76B8439E30BFDEFFF283871FF5528769B0A9F9374B888D4E39C31868F1C124B1C66F980CDD26DFECD07BCE32BFE77DFA0D0ED1B9FA9B4639941BF090EE86138CB3FBF0E774B8DDC0C1F937B1616F68FD8D0D2224DD408C2424EC7DF9CD93C3C625B72086697BE37062A3F87F15195810CD78FCA0B24F85A1A6DFACDC0F12E06789000A7258CD850D7E56067B1B2EF93A43EB44D2BFBF44C49121461B0EA3ED07DC8CB37CB069A00309021971EFCB6F7EE89BA47BA8ED37326FFFEF22838B646E4107DB787840DDC08907E23EFC7F1129C0A236D31B1B7ED86018F1F7F2C5DF5F6CBEC6D00CBD877558A7C537ABC4DE8B07BEC6F09407280F750B1BEDB7FA59905FDB49EC55FEF89B1C2E03DC3854B4D830331D3C2308FED08707AC87F9D47EF90DB3E8CD84F81A43E927296FF0A937B51F46FE83BCEAC1BCACCC6CE4EB0F264B3FC5BA992C1BDBFFEC90A5DF651C88F7F50793A59BCDDDE071C65B7EB3223194A8EEF24514D2D71AFE0D99A59FCD84522C8FF4CDA58F90FDDDA4D3ECB7DFECA0FC54BC6A357CF08D0CC7E5D97F7F811A1F57B7D90722DB7BA3BF1E60DFF5BFFAD918F2264F7953F3CD031A1CCEAD7CE61F2649BE0AB3F7BC2A10A345B4DDF010048C87B87CB061D09D0EBC9723DF7DE3C3DE941A1C6CBB41117DED04E1CF2D1906B55BBCE137ABE87E2E867E0B9EFFD964F781717EF343BC99BF7F58ACFDCD0CF9F15D8180D590AC58E6B5FDEEF15D590DD40FE84F5A29C92EF22FAA595E36FCE9E3BBAFD6F4F62297BF9EE64D71E1403C2698CB7C8A3E1D50D3E66C795EBDACAB555E33F63E46A689F95A27E18BBCCD66599B1DD76D719E4D5BFA7A8A400B49849FCCCA35846531C96767CB2FD7ED6ADDD290F3C5A40C5CD1C77737F7FFF86E0FE7C75FAEF057F34D0C81D02C6808F9974BCE7F58BC9F6565D399B421102744FDCF73FA5CE6B2A59FF9C5B585F4A25ADE129092EF69BECA9733D2066FF2C5AA2460CD97CBD7D9653E8CDBCD340C29F6F869915150B0F029289F184F37A39EBD2EA803FF0DD71FFD49EC3A5BBC3BFA7F020000FFFF956751DACAC60100, '4.3.1')

GO
--'Drop Index UQ__SiteUsers_IdentityProviderAndIdentityClaim on cc_SiteUsers'
Declare @SchemaName nvarchar(50), @TableName nvarchar(100), @SchemaTableName nvarchar(151), @SqlCmd nvarchar(512), @IndexName nvarchar(100);
Select @SchemaName = 'dbo', @TableName = 'cc_SiteUsers', @IndexName = 'UQ__SiteUsers_IdentityProviderAndIdentityClaim';
Set @SchemaTableName = @SchemaName + '.' + @TableName;
If OBJECT_ID(@SchemaTableName,'U') is null Begin
	Print 'Table ' + IsNull(@SchemaTableName,'???') + ' does not exist.';
End Else Begin
	IF EXISTS (Select name from sys.indexes si Where si.name = @IndexName and si.object_id = OBJECT_ID(@SchemaTableName,'U')) Begin
		Print 'Index ' + @IndexName + ' exists.';
	End Else Begin
		Create unique index [UQ__SiteUsers_IdentityProviderAndIdentityClaim] on dbo.cc_SiteUsers( UserIdentityProvider, UserIdentityClaim );
		Print 'Created Index ' + @IndexName;
	End;
END;
GO
